<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>async和await</title>
</head>

<body>

    <script src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js" charset="UTF-8"></script>
    <script>
        async function Show(params) {
            let a = 12;
            let b = 5;

            try {
                let data = await $.ajax({
                    url: "./data1.json",
                    dataType: "json"
                })
                alert(a + b + data.name)
            } catch (error) {
                console.log("读取失败");
            }
        }
        Show();
    </script>
    <!-- 
        使用try catch把容易出错的代码放到里面
     -->
</body>

</html>